package jdsk.iria;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class Welcome extends Activity {
	
	/****************************************************************
	 * IRIA Version 1.5.8
	 * Written by:
	 * Jaime Martinez, Kelly Taylor, Sylvia Perez
	 * 
	 ****************************************************************/

	private String studentName;
	private String teacherName;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_welcome);

		// used for custom font
		TextView txt = (TextView) findViewById(R.id.TextView01);
		Typeface font = Typeface
				.createFromAsset(getAssets(), "Courier_New.ttf");
		txt.setTypeface(font);

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_welcome, menu);

		return true;
	}

	/**
	 * Handles the start button being clicked. opens the MainActivity UI
	 * 
	 * @param view
	 */
	public void startButtonClick(View view) {

		teacherName = ((EditText) findViewById(R.id.editText2)).getText()
				.toString();
		studentName = ((EditText) findViewById(R.id.editText1)).getText()
				.toString();

		if (teacherName.equals("") || studentName.equals("")) {
			Toast.makeText(this, "Teacher and Student Must be Filled Out",
					Toast.LENGTH_LONG).show();

		} else {

			Intent myIntent = new Intent(Welcome.this, MainActivity.class);
			myIntent.putExtra("studentName",
					((EditText) findViewById(R.id.editText2)).getText()
							.toString());
			myIntent.putExtra("teacherName",
					((EditText) findViewById(R.id.editText1)).getText()
							.toString());
			Welcome.this.startActivity(myIntent);
		}

	}

	/**
	 * Handles the reset button being clicked. resets all test fields
	 * @param view
	 */
	public void resetButtonClick(View view) {
		TextView t1 = (TextView) findViewById(R.id.editText1);
		TextView t2 = (TextView) findViewById(R.id.editText2);
		t1.setText("");
		t2.setText("");
	}

}
